package ncku.account.data;

//交易子細目
public class AbstractSubTransaction {
	private static volatile long currentId = 0;
	
	private long id;
	private int amount;
	private String description;
	
	
	//指定SubTransaction id
	private static synchronized void setId(AbstractSubTransaction SubTransaction) {
		if (currentId==Long.MAX_VALUE) throw new RuntimeException("Transaction counter has an overflow"); //$NON-NLS-1$
		SubTransaction.id = currentId++;
	}
	
	//建構一筆新的SubTransaction
	public AbstractSubTransaction(String description, int amount){
		super();
		this.description = description;
		this.amount = amount;
		setId(this);
	}
	
	public int getSubAmount(){
		return this.amount;
	}
	
	public String getSubStringAmount(){
		return Integer.toString(this.amount);
	}
	
	public String getSubDescription(){
		return this.description;
	}
	
	public void setSubAmount(int amount){
		this.amount = amount;
	}

}
